# coding: utf-8

from elasticsearch import Elasticsearch
from elasticsearch import helpers

es = Elasticsearch(hosts="172.16.202.33:9200")
# es的批量其实就是做一个列表，一个命令+数据成对
# body = [
#     # 上面这个数据的id是es自己生成的
#     {'index': {"_id": "1"}},
#     {"title": "我是title", "name": "我是name", "age": 12345},
#     {'index': {"_id": "2"}},
#     {"title": "我是title", "name": "我是name", "age": 12345}
# ]
# es.bulk(index='wangsir', doc_type='user', body=body)

body = [
    {'update': {"_id": 1000}},
    {"doc": {'title': '我是新的title'}}
]
es.bulk(index='wangsir', doc_type='user', body=body)

# body = [
#     {'delete': {"_id": 1}},
# ]
# es.bulk(index='wangsir', doc_type='user', body=body)



# helpers.bulk(client=es, actions=)
